﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace OS.Instructions
{
    class BranchOnTrue : Instruction
    {
        public BranchOnTrue()
        {
        }//end default constructor

        /// <summary>
        /// Executes the the BT instruction
        /// </summary>
        public override void ExecuteBTInstruction()
        {
            Trace.WriteToTrace("Executing instruction: " + QueueManager.readyQueue.Peek().register_IR);

            //If the toggle register C is set to true, branch
            //If the toggle register C is not set to true, do nothing
            if (CPU.toggle_C)
            {
                CPU.instructionCounter_IC = int.Parse(CPU.instructionRegister_IR.Substring(2, 2));
                Trace.WriteToTrace(CPU.instructionCounter_IC + " stored in Instruction Counter.");
            }
            else
            {
                Trace.WriteToTrace("Toggle C is false. No action taken.");
            }

            CPU.SI = 0;
        }//end ExecuteInstruction
    }//end BranchOnTrue
}//end OS.Instructions
